<?php

require_once '/DAL/DbHelper.php';
require_once '/Model/ApplicationEntity.php';

/**
 * The functions for seretary
 * @author Kun.Huang
 * Date : 27/5/2013
 */
class Controller_Advisor {

    public $ControllerName = 'Controller_Advisor';
    public $DbHelper = null;
    public $UserEntity = null;

    /**
     *  the default Constructor
     */
    public function __construct() {
        $this->DbHelper = new DbHelper();
        $this->UserEntity = $_SESSION["UserEntity"];
    }

    /**
     * Accept Application
     * @param type $entity
     * @return type
     */
    public function AcceptApplication($entity) {
        $strSQL = "call Proc_Busi_Advisor_Accept(?,?,?,?,?,?,?)";
        $parameters[] = $entity->rowApplicationID;
        $parameters[] = $entity->rowHandleSchoolID;
        $parameters[] = $entity->rowStateID;
        $parameters[] = $entity->rowActionUserID;
        $parameters[] = $entity->rowAdvisorID; // extra
        $parameters[] = $entity->newActionUserID;
        $parameters[] = $entity->newActionStateID;
        $res = $this->DbHelper->execProcedures($strSQL, $parameters);
        return $res;
    }

    /**
     * Finalise the Application
     * @param type $entity
     * @return type
     */
    public function FinaliseApplication($entity) {
        $strSQL = "call Proc_Busi_Advisor_FinialiseApplication(?,?,?,?,?,?,?)";
        $parameters[] = $entity->rowApplicationID;
        $parameters[] = $entity->rowHandleSchoolID;
        $parameters[] = $entity->rowStateID;
        $parameters[] = $entity->rowActionUserID;
        $parameters[] = $entity->newActionUserID;
        $parameters[] = $entity->newActionStateID;
        $parameters[] = $entity->newActionCommnet;
        $res = $this->DbHelper->execProcedures($strSQL, $parameters);
        return $res;
    }

    /**
     * get the can be assign and finalised function
     */
    public function QueryApplicationDetail($SchoolID, $ApplicationTypeID, $AdvisorID) {
        $strSQL = "call Proc_Busi_Advisor_QueryDetails(?,?,?)";
        $parameters[] = $SchoolID;
        $parameters[] = $ApplicationTypeID;
        $parameters[] = $AdvisorID;
        $res = $this->DbHelper->execProcedures($strSQL, $parameters);
        return $res;
    }

    //Proc_Busi_Advisor_TypeSummaryOfSchool
    public function QueryApplicationSummary($SchoolID, $AdvisorID) {
        $strSQL = "call Proc_Busi_Advisor_QuerySummary(?,?)";
        $parameters[] = $SchoolID;
        $parameters[] = $AdvisorID;
        $res = $this->DbHelper->execProcedures($strSQL, $parameters);
        return $res;
    }

}

?>
